package com.matu.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import org.json.simple.parser.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.matu.domain.StationVelo;
import com.matu.service.ServiceJCDecaux;


@Controller
public class VeloController {
	
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
	
	@RequestMapping(value = "/velo", method = RequestMethod.GET)
	public String home1(Locale locale, Model model, HttpServletRequest request) {
		logger.info("Welcome home! The client locale is {}.", locale);
		
		ServiceJCDecaux sJCDecaux = new ServiceJCDecaux();
		ArrayList<StationVelo> listStationVelosDisp = new ArrayList<StationVelo>();
		try {
			listStationVelosDisp = sJCDecaux.getStations();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		model.addAttribute("listStationVelosDisp", listStationVelosDisp);
		
		return "velo";
	}
	

}
